// axios 公共配置
// 基地址
axios.defaults.baseURL = 'https://geek.itheima.net'
axios.interceptors.request.use((config) => {
    const token = localStorage.getItem('token')
    token && (config.headers.Authorization = `Bearer ${token}`)
    return config
}, (error) => {
    return Promise.reject(error)
})
axios.interceptors.response.use((response) => {
    const result = response.data
    return result
}, (error) => {

    if (error.response.status == 401) {
        alert('身份验证失败，请重新登陆')
        localStorage.clear()
        location.href = '../login/index.html'
    }
})